The present invention relates in general to computer image processing and in particular to systems and methods for providing double-buffering for image data using copy-on-write semantics.
Computer display devices typically display images by coloring each of a number of independent pixels (picture elements) that cover the display area. The computer system determines a color value for each pixel using various well-known graphics processing techniques. Once color values are generated, pixel data representing the color values is written to a “frame buffer,” an area of memory with sufficient capacity to store color data for each pixel of the display device. To display an image, scanout control logic reads the pixel values sequentially from the frame buffer and converts them to analog signals that produce the desired pixel colors on the display device. Scanout is generally performed at a constant frame rate, e.g., 80 Hz.
The demand for access to the frame buffer memory can be quite large. For instance, scanout at 80 Hz for a 1024×768 pixel display with 32-bit color requires the ability to read 2 Gbits per second. At the same time, data for the next frame is also being written to the frame buffer, often at high rates. Thus, memory bandwidth is generally a scarce resource in image processing systems.
To improve memory access times and to prevent undesirable visual artifacts that can result if pixel data in the frame buffer is updated during scanout of a frame, many graphics processing systems (or other image generation systems) provide a double-buffered frame buffer, as shown in FIG. 1. Frame buffer 100 includes two memory spaces 102, 104, each of which has sufficient capacity to store pixel data for a complete display frame. At a given time, one memory space (e.g., space 102) is designated as the “back” buffer while the other (e.g., space 104) is designated as the “front” buffer. Applications 106, 108 write pixel data to respective sections 110, 112 of the back buffer (memory space 102) while the front buffer (memory space 104) is read and displayed by scanout control logic 114. Memory spaces 102, 104 are generally designed to be accessed in parallel, to reduce conflicts between updating and scanout operations. At the end of each scanout frame, the buffers are swapped, i.e., the memory space 102 designated as the front buffer becomes the back buffer and vice versa. The next frame is written to the new back buffer (e.g., memory space 104) while the new front buffer (memory space 102) is scanned out.
To avoid writing an entire frame to the back buffer during each scanout pass, some existing systems also copy the content of the back buffer to the front buffer at the time of swapping, so that the back buffer can be updated rather than being completely rewritten. That is, at the end of a scanout frame, data from the back buffer (memory space 102) is copied (e.g., by a block transfer) to the front buffer (memory space 104). Memory references (e.g., pointers or base addresses) used by applications 106, 108 and scanout control logic 114 are typically swapped at this point so that during the next scanout pass, the memory space 102 that was used as the back buffer is scanned out while the other memory space 104 receives pixel data updates. This procedure can reduce demand for write access during the frame interval, but the peak demand for memory bandwidth can be quite high due to the need to copy an entire frame of pixel data at the end of each frame.
It is often the case that some or all of the pixel values do not change during a particular frame interval. Nevertheless, at the end of the frame, data for every pixel is copied, regardless of whether a particular pixel value was updated or not. The copying of unmodified pixel data results in a waste of memory bandwidth.
This problem can be compounded in proposed desktop compositor systems. In general, such systems differ from the system of FIG. 1 in that pixel data generated by applications or other data sources is not written directly to the frame buffer. Instead, for each application, a dedicated area of “drawing” memory is provided as a buffer for storing pixel data generated by that application. A desktop compositor combines data from the drawing memories of various applications to generate a desktop pixel value, which is stored in a desktop frame buffer. The desktop frame buffer is then scanned out to produce the display image. The drawing memories can be double-buffered, with applications writing to a “back” drawing buffer and the desktop compositor reading from a “front” drawing buffer. Likewise, the desktop frame buffer can also be double-buffered, with the desktop compositor writing to a “back” desktop buffer and the scanout control logic reading from a “front” desktop buffer. Such systems are desirable because visual effects such as transparent or translucent windows are more easily implemented. In addition, providing each application with a separate drawing memory reduces contention among applications for write access to the frame buffer.
Such systems, however, do not reduce the copying of unmodified pixel data between the various buffers. In implementations where application data is copied between two drawing buffers to support incremental updating of the application image, the amount of data that has to be moved can become prohibitive.
It would therefore be desirable to provide a double-buffering system that avoided copying of unmodified pixel data, thereby reducing the demand for memory bandwidth.